import rclpy
from sentry_interfaces.msg import RobotHP
from rclpy.node import Node
from std_msgs.msg import String
from autoaim_interfaces.msg import Armors
from rclpy.qos import qos_profile_sensor_data
from geometry_msgs.msg import Pose
class UnityBridgeAim(Node):

    def __init__(self):
        super().__init__('unity_bridge')
        # ROSTOUNITY发布端
        self.publisher_ = self.create_publisher(Pose, 'armors_transform', 10)
        # 装甲板数据接收端
        self.subscription_armors = self.create_subscription(Armors,'/detector/armors',self.armors_unity_callback,qos_profile_sensor_data)
        self.subscription_armors  # 防止被垃圾回收

    def armors_unity_callback(self, msg):
        if msg.armors:
            zjb_transform= msg.armors[0].pose
            self.publisher_.publish(zjb_transform)
        
def main(args=None):
    rclpy.init(args=args)

    UnityBridge_ = UnityBridgeAim()

    rclpy.spin(UnityBridge_)

    UnityBridge_.destroy_node()
    rclpy.shutdown()


if __name__ == '__main__':
    main()